package com.macrog.service.impl;

import com.macrog.entity.*;
import com.macrog.mapper2.TaxpayerMapper;
import com.macrog.service.TaxpayerService;
import com.macrog.utils.SqlHelper;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 *
 * @author guohong
 * @date 2018/6/19
 */
@Service
public class TaxpayerServiceImpl implements TaxpayerService {
    @Autowired
    private TaxpayerMapper taxpayerMapper;

    @Autowired
    private SqlSessionFactory sqlSessionFactory1;


    @Override
    public Taxpayer getById(String nsrsbh) {
        TaxDTO taxDTO = new TaxDTO();
        TaxBaseInfo baseInfo = taxpayerMapper.getTaxBaseInfo(nsrsbh);
        TaxManagerInfo managerInfo = taxpayerMapper.getTaxManagerInfo(nsrsbh);
        TaxInvestorInfo investorInfo = taxpayerMapper.getTaxInvestorInfo(nsrsbh);
        taxDTO.setBaseInfo(baseInfo);
        taxDTO.setManagerInfo(managerInfo);
        taxDTO.setInvestorInfo(investorInfo);
        return taxpayerMapper.getById(nsrsbh);
    }

    @Override
    public String getSql() {
        SqlSession sqlSession = sqlSessionFactory1.openSession();
        String getTaxInvestorInfo = SqlHelper.getMapperSql(sqlSession, TaxpayerMapper.class, "getTaxInvestorInfo", null);
        System.out.println(getTaxInvestorInfo);
        return getTaxInvestorInfo;
    }
}
